home *** CD-ROM | disk | FTP | other *** search
- Path: debbie.ee.queensu.ca!majeed
- From: majeed@qucdntri.ee.queensu.ca
- Newsgroups: comp.lang.c
- Subject: [Q] Help. Initializing crashes program!!!
- Date: 28 Feb 96 08:44:28 -0500
- Organization: Queen's University EE Department
- Message-ID: <1996Feb28.084428.1@debbie.ee.queensu.ca>
- NNTP-Posting-Host: debbie.ee.queensu.ca
-
- Hello.
-
- Alright, here's are some definitions:
-
- #define N 8
- #define L 13
-
- typedef struct
- {
- float I[L],Q[L];
- } f_short_array;
-
- Here's a subroutine:
- void PROC1(void)
- {
- int m,j;
- ... (other declarations)
- static f_short_array poly_reg[N];
-
- /* initializing */
- for (m = 0; m < N; m++)
- {
- for (j = 0; j < L; j++)
- {
- poly_reg[m].I[j] = 0.0;
- poly_reg[m].Q[j] = 0.0;
- }
- }
-
- ... (more code)
-
- /* shifting */
- for (m = 0; m < N; m++)
- {
- for (j = L-1; j > 0; j--)
- {
- poly_reg[m].I[j] = poly_reg[m].I[j-1];
- poly_reg[m].Q[j] = poly_reg[m].Q[j-1];
- }
- }
-
- ... (more code)
- }
-
- Why is it that if I leave the initialization as above, the program crashes
- at run-time when there were no compiler/linker warnings or errors? But,
- when I comment that whole section out, i.e. no array clearing, the program
- doesn't crash. I don't get it. Data is still being assigned to the
- elements of poly_reg later on in the program and that doesn't make the
- program crash! Is this a memory-related problem. I don't see how. I
- counted the total number of bytes that all my arrays (from the whole
- proram) sum up to and that number was about 20000. When I run this
- program on a VAX I get an error which goes something like "Access
- Violation".
-
- That's what I hate about C. A problem which seems to occur in one place may
- be caused by a problem elsewhere. Could someone please advice me on what
- the bug is and how I can fix it? Thanks in advance.
-